package com.kitty.game.fight.book;

import com.kitty.game.fight.bean.Fight;
import com.kitty.game.fight.bean.FightObject;
import com.kitty.common.utils.SpringUtils;
import com.kitty.game.fight.service.FightMessageService;
import com.kitty.game.fight.util.FightMessageUtil;

/**
 * 魔引
 * 物理攻击命中对方的时候，有几率消耗对方的法力
 */
public class MoYinSkillProcessor extends BookSkillProcessor {

	@Override
	public Object effect(Fight fight, FightObject effector, FightObject target, Object... args) {
		if (!commonCheck(fight, effector, target)) {
			return false;
		}
		int costMp = (int) (target.getCurrMana() * 0.1);

		effector.reduceMp(costMp);
		FightMessageService fightMessageService = SpringUtils.getFightMessageService();
		FightMessageUtil.sendFightPackage(fight,
				fightMessageService.decreaseMana(effector.getId(), target.getId(), costMp, 0));
		FightMessageUtil.sendFightPackage(fight, fightMessageService.updateObjectInfo(target));

		return true;
	}

}
